import api from "@/api";
const state = {
  user: {},
  roles: ["add"],
};

const mutations = {
  UPDATE_USER: (state, data) => {
    state.user = data;
  },
  UPDATE_roles: (state, data) => {
    state.roles = data;
  },
};

const actions = {
  updateUser(store) {
    return api.getUser({}).then((res) => {
      let { roles } = res;
      store.commit("UPDATE_roles", roles);
      store.commit("UPDATE_USER", res);
    });
  },
};

export default {
  state,
  mutations,
  actions,
};
